﻿using VipSys.DataLayer;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using VipSys.SystemEntity;
using System.Configuration;
using System.Collections.Generic;

namespace VipSys.TDD
{
    
    
    /// <summary>
    ///这是 UserAccessTest 的测试类，旨在
    ///包含所有 UserAccessTest 单元测试
    ///</summary>
    [TestClass()]
    public class UserAccessTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///获取或设置测试上下文，上下文提供
        ///有关当前测试运行及其功能的信息。
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                SystemParam.Instance.ConnectionString = "";
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region 附加测试特性
        // 
        //编写测试时，还可使用以下特性:
        //
        //使用 ClassInitialize 在运行类中的第一个测试前先运行代码
        [ClassInitialize()]
        public static void MyClassInitialize(TestContext testContext)
        {
            SystemParam.Instance.ConnectionString
           = ConfigurationManager.AppSettings["AccessConnection"].ToString();
        }
        //
        //使用 ClassCleanup 在运行完类中的所有测试后再运行代码
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //使用 TestInitialize 在运行每个测试前先运行代码
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //使用 TestCleanup 在运行完每个测试后运行代码
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///Add 的测试
        ///</summary>
        [TestMethod()]
        public void AddTest()
        {

            UserAccess target = new UserAccess(); // TODO: 初始化为适当的值
            User user = null; // TODO: 初始化为适当的值
            user = new User() { ExceptRoomie = "yehui", Bak = "单元测试" };
            short expected = 0; // TODO: 初始化为适当的值
            short actual;
            actual = target.Add(user);
            Assert.AreEqual(expected, actual);
           // Assert.Inconclusive("验证此测试方法的正确性。");
        }

        /// <summary>
        ///Edit 的测试
        ///</summary>
        [TestMethod()]
        public void EditTest()
        {
            UserAccess target = new UserAccess(); // TODO: 初始化为适当的值
            User user = null; // TODO: 初始化为适当的值
            string szID="56";
            short shRet = UserAccess.Instance.GetUser(szID, ref user);
            if (shRet != SystemData.ReturnValue.OK)
                return;
            user.ExceptRoomie = "雅婷" + System.DateTime.Now.ToString();
            short actual = UserAccess.Instance.Edit(user);
            short expected = 0; // TODO: 初始化为适当的值
            
            actual = target.Edit(user);
            Assert.AreEqual(expected, actual);
           // Assert.Inconclusive("验证此测试方法的正确性。");
        }

        /// <summary>
        ///GetUserPageList 的测试
        ///</summary>
        [TestMethod()]
        public void GetUserPageListTest()
        {
            UserAccess target = new UserAccess(); // TODO: 初始化为适当的值
            User query = null; // TODO: 初始化为适当的值
            List<User> lstUser = null; // TODO: 初始化为适当的值
            List<User> lstUserExpected = null; // TODO: 初始化为适当的值
            string szSchools = string.Empty; // TODO: 初始化为适当的值
            short expected = 0; // TODO: 初始化为适当的值
            short actual;
            actual = target.GetUserPageList(query, ref lstUser, szSchools);
          //  Assert.AreEqual(lstUserExpected, lstUser);
            Assert.AreEqual(expected, actual);
          //  Assert.Inconclusive("验证此测试方法的正确性。");
        }

        /// <summary>
        ///GetUserList 的测试
        ///</summary>
        [TestMethod()]
        public void GetUserListTest()
        {
            UserAccess target = new UserAccess(); // TODO: 初始化为适当的值
            User query = null; // TODO: 初始化为适当的值
            query = new User();
            List<User> lstUser = null; // TODO: 初始化为适当的值
            List<User> lstUserExpected = null; // TODO: 初始化为适当的值
            string szSchools = string.Empty; // TODO: 初始化为适当的值
            short expected = 0; // TODO: 初始化为适当的值
            short actual;
            actual = target.GetUserList(query, ref lstUser, szSchools);
           // Assert.AreEqual(lstUserExpected, lstUser);
            Assert.AreEqual(expected, actual);
          //  Assert.Inconclusive("验证此测试方法的正确性。");
        }

        /// <summary>
        ///GetUserList 的测试
        ///</summary>
        [TestMethod()]
        public void GetUserListTest1()
        {
            UserAccess target = new UserAccess(); // TODO: 初始化为适当的值
            string szRoom = string.Empty; // TODO: 初始化为适当的值
            string szHotel = string.Empty; // TODO: 初始化为适当的值
            List<User> lstUser = null; // TODO: 初始化为适当的值
            List<User> lstUserExpected = null; // TODO: 初始化为适当的值
            short expected = 0; // TODO: 初始化为适当的值
            short actual;
            szRoom = "402";
            szHotel = "快捷酒店";
            if (string.IsNullOrEmpty(szRoom) || string.IsNullOrEmpty(szHotel))
                return ;
            actual = target.GetUserList(szRoom, szHotel, ref lstUser);
            //Assert.AreEqual(lstUserExpected, lstUser);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }

        /// <summary>
        ///GetUser 的测试
        ///</summary>
        [TestMethod()]
        public void GetUserTest()
        {
            UserAccess target = new UserAccess(); // TODO: 初始化为适当的值
            string szID = string.Empty; // TODO: 初始化为适当的值
            szID = "52";
            User user = null; // TODO: 初始化为适当的值
            User userExpected = null; // TODO: 初始化为适当的值
            short expected = 0; // TODO: 初始化为适当的值
            short actual;
            actual = target.GetUser(szID, ref user);
           // Assert.AreEqual(userExpected, user);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
    }
}
